package com.pswv2.backstage.territory.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.pswv2.backstage.category.servic.CategoryService;
import com.pswv2.backstage.keyword.service.KWordService;
import com.pswv2.backstage.territory.servic.TerritoryService;
import com.pswv2.bub.bsc.dao.po.Category;
import com.pswv2.bub.bsc.dao.po.Territory;
import com.pswv2.util.ExtraSpringHibernateTemplate;

@Service
public class TerritoryServiceImp implements TerritoryService {
	private static Class<?> poc = Territory.class;
	@Autowired
	private ExtraSpringHibernateTemplate extraSpringHibernateTemplate;
	@Override
	public void add(Territory territory) {
		// TODO Auto-generated method stub
		extraSpringHibernateTemplate.getHibernateTemplate().save(territory);
	}

	@Override
	public Territory queryById(int id) {
		// TODO Auto-generated method stub
		return extraSpringHibernateTemplate.findFirstOneByPropEq(poc, "territoryId", id);
	}

	@Override
	public void updata(Territory territory) {
		// TODO Auto-generated method stub
		extraSpringHibernateTemplate.getHibernateTemplate().update(territory);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Territory> queryAll() {
		// TODO Auto-generated method stub
		return (List<Territory>) extraSpringHibernateTemplate.findAll(poc);
	}

	

	@Override
	public Category queryByName(String name) {
		// TODO Auto-generated method stub
		return null;
	}
}
